package com.parktech.sun.domain.model.addressbook;

import com.parktech.sun.domain.model.system.User;

import javax.persistence.*;
import java.io.Serializable;
import java.util.Date;
import java.util.HashSet;
import java.util.Set;


/**
 * User: Think
 * Date: 2010-12-20
 * Time: 1:58:08
 */
@Entity
public class ContactMember implements Serializable {
    private Set<ContactGroup> contactGroups = new HashSet<ContactGroup>();
    private Long id;
    private String name;
    private String company;
    private String mobile;
    private String telephone;
    private String address;
    private String position;
    private String email;
    private boolean isSubscribed = false;
    private Date createDatetime = new Date();
    private Date updateDatetime = new Date();
    private User creator;
    private User modifier;
    private String description;
    //////////////////////////////// /////////////////////////////////////
    private String tempGroupIDConcat ;

    @Transient
    public String getTempGroupIDConcat() {
        return tempGroupIDConcat;
    }

    public void setTempGroupIDConcat(String tempGroupIDConcat) {
        this.tempGroupIDConcat = tempGroupIDConcat;
    }

    @ManyToMany(cascade = { CascadeType.PERSIST, CascadeType.MERGE },fetch = FetchType.LAZY)
    @JoinTable(name = "so_contact_group_member",
            joinColumns = {@JoinColumn(name = "member_id", referencedColumnName = "id", table = "so_contact_member")},
            inverseJoinColumns = {@JoinColumn(name = "group_id", referencedColumnName = "id", table = "so_contact_group")})
    public Set<ContactGroup> getContactGroups() {
        return contactGroups;
    }

    public void setContactGroups(Set<ContactGroup> contactGroups) {
        this.contactGroups = contactGroups;
    }

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    @Column(name = "name", length =66,nullable = false)
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @Column(name = "company", length =66)
    public String getCompany() {
        return company;
    }

    public void setCompany(String company) {
        this.company = company;
    }

    @Column(name = "mobile", length =44)
    public String getMobile() {
        return mobile;
    }

    public void setMobile(String mobile) {
        this.mobile = mobile;
    }

    @Column(name = "telephone", length =44)
    public String getTelephone() {
        return telephone;
    }

    public void setTelephone(String telephone) {
        this.telephone = telephone;
    }

    @Column(name = "address", length =255)
    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    @Column(name = "position", length =100)
    public String getPosition() {
        return position;
    }

    public void setPosition(String position) {
        this.position = position;
    }

    @Column(name = "email", length =44)
    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    @Transient
    public boolean isSubscribed() {
        return isSubscribed;
    }

    public void setSubscribed(boolean subscribed) {
        isSubscribed = subscribed;
    }

    @Column(name = "create_datetime", nullable = false)
    public Date getCreateDatetime() {
        return createDatetime;
    }

    public void setCreateDatetime(Date createDatetime) {
        this.createDatetime = createDatetime;
    }

    @Column(name = "update_datetime", nullable = false)
    public Date getUpdateDatetime() {
        return updateDatetime;
    }

    public void setUpdateDatetime(Date updateDatetime) {
        this.updateDatetime = updateDatetime;
    }

    @ManyToOne
    @JoinColumn(name = "creator_id")
    public User getCreator() {
        return creator;
    }

    public void setCreator(User creator) {
        this.creator = creator;
    }

    @ManyToOne
    @JoinColumn(name = "modifier_id")
    public User getModifier() {
        return modifier;
    }

    public void setModifier(User modifier) {
        this.modifier = modifier;
    }

    @Column(name = "description",length = 255)
    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }
}
